package com.easyjob.authlogin.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Const
 */
@Configuration
public class WeChatConfig {

    @Value("${wx.appId}")
    private String appId;

    @Value("${wx.secret}")
    private String secret;

    @Bean
    public WxMpService wxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();
        WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
        config.setAppId(appId);      // 设置微信公众号appid
        config.setSecret(secret);    // 设置微信公众号secret
        config.setToken("your_token"); // 如果需要接收消息需配置
        wxMpService.setWxMpConfigStorage(config);
        return wxMpService;
    }
}
